package com.yhb.service;

import com.yhb.controller.out.vo.ThirdAuthVo;
import com.yhb.controller.vo.AdminAuthVo;
import com.yhb.controller.vo.AuthVo;
import com.yhb.model.Certificate;
import com.yhb.model.User;
import com.yhb.model.AdminUser;
import lombok.NonNull;
import me.edzh.spring.bootstrap.model.Tuple;

import java.util.Date;
import java.util.List;

public interface UserService {
    AuthVo login(String userName, String pwd);
    String adminGetVerifyCode(String mobile);
    AdminAuthVo adminVerify(String token, String verifyCode);

    User getUser(String id);

    AdminUser getAdminUser(String id);

    User getUserByMobilePhone(String mobilePhone);

    String getInvitorId(String userId);


    User getInvitor(String userId);

    AuthVo register(User user, String inviteCode);

    User getUserByInviteCode(String inviteCode);

    Long getInviteeCountRegisterAfter(String invitorId, Date time);

    /**
     * 返回用户名字, 如果用户经过实名认证, 则返回真实姓名, 否则, 返回昵称
     */
    String getUserNameByUserId(String userId);
    String getUserNameByUserIdUnmasked(String userId);

    /**
     * 返回邀请人名字, 如果邀请人经过实名认证, 则返回真实姓名, 否则, 返回昵称
     */
    String getUserNameByInviteCode(String inviteCode);

    void addCertificateInfo(Certificate certificate, User user);

    Certificate getCertificate(String userId);

    void resetCertificate(User user);

    @NonNull
    List<String> getInviteeIds(String userId);

    User userByIdCodeMd5(String md5);

//    void updateMd5();

    void modifyUser(User user);

    /**
     * 粉丝页面, 激活排行
     * @param type DAILY / MONTHLY
     */
    List<Tuple<User, Long>> getFollowerVipActivationRank(String type, String invitorId);

    List<String> getAllUserId();
    List<User> getAllUser();
    List<User> searchUser(String key);

    List<String> getRootUserIds();

    /**
     * @return sms token
     */
    String getChangePhoneNumberSms(String userId, String newPhoneNumber);

    void verifyChangePhoneNumber(String userId, String smsToken, String verifyCode);

    /**
     * @return sms token
     */
    String getResetPasswordSms(String phoneNumber);

    void verifyResetPassword(String smsToken, String verifyCode, String newPassword);

    /**
     * 发放会员
     * @param days 续时长, 单位天, Long.max 为终身
     */
    void earnVip(User user, int days);
    void earnVip(User user, boolean isPermanent, Date endDate);
    void earnVip(User user, boolean isPermanent, Date startDate, Date endDate);

    /**
     * 发放皇冠会员
     * @param days 持续时长, 单位天, Long.max 为终身
     */
    void earnPrimeVip(User user, int days);

    boolean isVipInTime(User user, Date moment);
    boolean isPermanentVipInTime(User user, Date moment);
    boolean isPrimeVipInTime(User user, Date moment);

    void checkVipValidation(String user);

    void checkInvitorVIPBonus(User invitee);
    void checkInvitorVIPBonusMonthly(User invitor, Date start, Date end);


    void setUserActive(String userId);

    Long isActive(String userId, Date startTime, Date endTime);
    Long getVipStartInRangeCount(List<String> userIds, Date startTime, Date endTime);

    int isVipConsumeOccurredInTimeRange(String userId, Date startTime, Date endTime);
    int isPrimeVipConsumeOccurredInTimeRange(String userId, Date startTime, Date endTime);

    ThirdAuthVo getThirdAuthToken(String appId, String authCode);
    String genThirdAuthCode(String appId, String userId);

    User userByThirdAuthToken(String appId, String token);

    Long certificatingFollowerCount(String invitorId, Date start, Date end);

}
